#include "manano_common.h"

#include "mdtx-online/indicator/indicator_type_s2_zscore.h"
namespace indi = mdtx::online::indicator;

using smoothz = unary1<indi::smoothz>;
using smoothz_ew = unary1<indi::smoothz_ew>;
using smoothz_cu = unary1<indi::smoothz_cu>;
using stdz = unary1<indi::stdz>;
using stdz_ew = unary1<indi::stdz_ew>;
using stdz_cu = unary1<indi::stdz_cu>;
using stdz_vw = binary1<indi::stdz_vw>;
using stdz_cuvw = binary1<indi::stdz_cuvw>;

void bind_indi_s2_zscore(py::module &m)
{
    auto mod = m.def_submodule("zscore", "Rolling zscore");
    {
        auto v = py::class_<smoothz>(mod, "smooth")
                     .def(py::init<int, int, double, double>(), py::arg("period"), py::arg("m_period"), py::arg("z"), py::arg("r"))
                     .def("run", &smoothz::run, py::arg("x"), "Run calc")
                     .def("run", &smoothz::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    Smoothed rolling zscore
                    Args:
                        period (int) : rolling window period
                        m_period (int) : smooth window
                        z (float64) : zscore threshold
                        r (float64) : attenuation factor)mydoc";
    }
    {
        auto v = py::class_<smoothz_ew>(mod, "smooth_ew")
                     .def(py::init<int, int, double, double>(), py::arg("period"), py::arg("m_period"), py::arg("z"), py::arg("r"))
                     .def("run", &smoothz_ew::run, py::arg("x"), "Run calc")
                     .def("run", &smoothz_ew::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    Smoothed rolling zscore, exponentially weighted
                    Args:
                        period (int) : rolling window period
                        m_period (int) : smooth window
                        z (float64) : zscore threshold
                        r (float64) : attenuation factor)mydoc";
    }
    {
        auto v = py::class_<smoothz_cu>(mod, "smooth_cu")
                     .def(py::init<int, double, double>(), py::arg("m_period"), py::arg("z"), py::arg("r"))
                     .def("run", &smoothz_cu::run, py::arg("x"), "Run calc")
                     .def("run", &smoothz_cu::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    Smoothed cumulative zscore
                    Args:
                        m_period (int) : smooth window
                        z (float64) : zscore threshold
                        r (float64) : attenuation factor)mydoc";
    }
    {
        auto v = py::class_<stdz>(mod, "zscore")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &stdz::run, py::arg("x"), "Run calc")
                     .def("run", &stdz::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    Standard rolling zscore
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<stdz_ew>(mod, "zscore_ew")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &stdz_ew::run, py::arg("x"), "Run calc")
                     .def("run", &stdz_ew::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    Exponentially weighted rolling zscore
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<stdz_cu>(mod, "zscore_cu")
                     .def(py::init())
                     .def("run", &stdz_cu::run, py::arg("x"), "Run calc")
                     .def("run", &stdz_cu::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    Cumulative zscore)mydoc";
    }
    {
        auto v = py::class_<stdz_vw>(mod, "zscore_vw")
                     .def(py::init<int>(), py::arg("period"))
                     .def("run", &stdz_vw::run, py::arg("x"), py::arg("w"), "Run calc")
                     .def("run", &stdz_vw::run2, py::arg("x"), py::arg("w"), "Run batch calc");
        v.doc() = R"mydoc(
                    Volume weighted rolling zscore
                    Args:
                        period (int) : rolling window period)mydoc";
    }
    {
        auto v = py::class_<stdz_cuvw>(mod, "zscore_cuvw")
                     .def(py::init())
                     .def("run", &stdz_cuvw::run, py::arg("x"), py::arg("w"), "Run calc")
                     .def("run", &stdz_cuvw::run2, py::arg("x"), py::arg("w"), "Run batch calc");
        v.doc() = R"mydoc(
                    Volume weighted cumulative zscore)mydoc";
    }
}
